package com.scuec.trainingmanagementsys.service.impl;

import com.scuec.trainingmanagementsys.entity.WeeklyAssessment;
import com.scuec.trainingmanagementsys.mapper.WeeklyAssessmentMapper;
import com.scuec.trainingmanagementsys.service.WeeklyAssessmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class WeeklyAssessmentServiceImpl implements WeeklyAssessmentService {
    @Autowired
    private WeeklyAssessmentMapper weeklyAssessmentMapper;

    @Override
    public int addWeeklyAssessment(WeeklyAssessment weeklyAssessment) {
        if (weeklyAssessment.getWsCreateTime() == null) {
            weeklyAssessment.setWsCreateTime(new Date());
        }
        return weeklyAssessmentMapper.addWeeklyAssessment(weeklyAssessment);
    }

    @Override
    public int deleteWeeklyAssessmentById(Integer weeklyAssessmentID) {
        return weeklyAssessmentMapper.deleteWeeklyAssessmentById(weeklyAssessmentID);
    }

    @Override
    public WeeklyAssessment findWeeklyAssessmentById(Integer weeklyAssessmentID) {
        return weeklyAssessmentMapper.findWeeklyAssessmentById(weeklyAssessmentID);
    }

    @Override
    public List<WeeklyAssessment> findAllWeeklyAssessments() {
        return weeklyAssessmentMapper.findAllWeeklyAssessments();
    }

    @Override
    public List<WeeklyAssessment> findWeeklyAssessmentsByTeacherId(Integer teacherID) {
        return weeklyAssessmentMapper.findWeeklyAssessmentsByTeacherId(teacherID);
    }

    @Override
    public int updateWeeklyAssessment(WeeklyAssessment weeklyAssessment) {
        return weeklyAssessmentMapper.updateWeeklyAssessment(weeklyAssessment);
    }

    @Override
    public List<WeeklyAssessment> findWeeklyAssessmentsByWeeklyReportID(Integer weeklyReportID) {
        return weeklyAssessmentMapper.findWeeklyAssessmentsByWeeklyReportID(weeklyReportID);
    }

    @Override
    public List<String> getWeeklyReports() {
        return null;
    }

    @Override
    public List<Map<String, Object>> findWeeklyAssessmentsByWeeklyReportIDWithDetails(Integer weeklyReportID) {
        return weeklyAssessmentMapper.findWeeklyAssessmentsByWeeklyReportIDWithDetails(weeklyReportID);
    }

    @Override
    public List<WeeklyAssessment> getWeeklyAssessmentsByReportId(Integer reportId) {
        return weeklyAssessmentMapper.getAssessmentsByReportId(reportId);
    }

    @Override
    public List<Map<String, Object>> getCommentsByReportId(Integer weeklyReportID) {
        return weeklyAssessmentMapper.getCommentsByReportId(weeklyReportID);
    }
}